package com.zzxy.spring5.test;

import com.zzxy.spring5.service.impl.AccountServiceImpl;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test {
    public static void main(String[] args) throws Exception {
        /*UserServiceImpl userService = new UserServiceImpl();
        System.out.println(userService);
        userService.setUsername("zhangsan");
        UserServiceImpl userService1 = new UserServiceImpl();
        System.out.println(userService1);
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        UserServiceImpl userService = (UserServiceImpl) context.getBean("userService");
        System.out.println("userService");
       userService.addUser();
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("beans.xml");
        UserServiceImpl userService1 = (UserServiceImpl) context.getBean("userService");
      System.out.println("userService1");
        userService1.addUser();*/
    /*public static void main(String[]args){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        context.getBean("user");*/
        //  Context.getClass().getMethod("close").invoke(Context);
        //ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans6.xml");
        //UserServiceImpl userService = context.getBean(UserServiceImpl.class);
        //Student student = (Student) context.getBean("student4");
        //System.out.println(userService);
        //TeacherController controller = context.getBean(TeacherController.class);
        //controller.register("zhangwuji","1234");
        /*StudentServiceImpl studentService1 = new StudentServiceImpl();
        studentService1.delStudent();
        IStudentService studentService = MyBeanFactoty.createStudentService();
        studentService.addStudent();
        studentService.delStudent();
        studentService.updateStudent();
        studentService.updateStudent();
        studentService.delStudent();
        IStudentService stuServiceProxy = (IStudentService) context.getBean("studentService");
        stuServiceProxy.delStudent();
        studentService.test();
        StudentServiceImpl studentService2 = context.getBean(StudentServiceImpl.class);
        studentService.test();
        BasicDataSource dataSourse = new BasicDataSource();
        dataSourse.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSourse.setUrl("jdbc:mysql://localhost:3306/spring5?serverTimezone=UTC");
        dataSourse.setUsername("root");
        dataSourse.setPassword("123456");
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourse);
        jdbcTemplate.update("insert into t_user values (null,?,?)","zhangwuji","123");*/
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans9.xml");
        /*MemberServiceImpl memberService = (MemberServiceImpl) context.getBean("memberService");
        memberService.addMember();*/
        AccountServiceImpl accountService = (AccountServiceImpl) context.getBean("accountService");
        accountService.transer("jack","rose",1000);
    }
}
